<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 14-8-5
  Time: 下午3:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <%@include file="../../includes/common.jsp" %>
    <title>编辑班级</title>
</head>
<body>
<div id="mainContent">
    <form class="form-horizontal">
        <fieldset>
            <!-- Form Name -->
            <legend></legend>
            <div class="control-group">
                <label class="control-label" for="classroomName">班级名称</label>

                <div class="controls">
                    <input id="classroomName" name="classroomName" type="text" value="${classroomInfo.name}">
                </div>
            </div>

            <div class="control-group">
                <label class="control-label" for="examinationName">结业试题</label>

                <div class="controls">
                    <input id="examinationName" name="examinationName" type="text"
                           value="${classroomInfo.examinationName}"
                           flag="examination" autocomplete="off">
                    <input type="hidden" name="examinationId" id="examinationId" value="${classroomInfo.examinationId}"
                           autoHidden="autoHidden">
                </div>
            </div>

            <div class="control-group">
                <label class="control-label" for="passScore">结业分数</label>

                <div class="controls">
                    <input id="passScore" name="passScore" type="text" value="${classroomInfo.passScore}">
                </div>
            </div>

            <div class="control-group">
                <label class="control-label" for="planTime">计划用时</label>

                <div class="controls">
                    <input id="planTime" name="planTime" type="text" value="${classroomInfo.planTime}">天
                </div>
            </div>

            <div class="control-group">
                <label class="control-label" for="memo">备注</label>

                <div class="controls">
                    <textarea class="textarea" id="memo" name="memo">${classroomInfo.memo}</textarea>
                </div>
            </div>
            <div class="control-group">
                <label class="control-label"></label>

                <div class="controls">
                    <input type="button" id="saves" class="btn btn-primary" onclick="save()"
                           value="<spring:message code="save"/>"/>
                    <input type="button" onclick="quit()" class="btn btn-primary"
                           value="<spring:message code="cancel"/>"/>
                </div>
            </div>
        </fieldset>
    </form>
</div>
</body>
</html>
<script type="text/javascript">
    var rules = {
        objInfo: {
            classroomName: {
                checkEmpty: ["classroomName", "班级名称"]
            },
            examinationName: {
                checkFrameEmpty: ["examinationId", "结业试题", "examinationName"]
            },
            passScore: {
                checkEmpty: ["passScore", "结业分数"]
            },
            planTime: {
                checkEmpty: ["planTime", "计划用时"]
            }
        }
    };

    function backFunc(data, returnObj) {
        returnObj.obj = $('#dictName');
        returnObj.errMsg = "<spring:message code="dictNameExist"/>！";
        if (data == "true") {
            returnObj.bool = true;
        }
        if (data == "false") {
            returnObj.bool = false;
        }

        return returnObj;
    }

    function save() {
        if (!JC.validate(rules)) return;
        $("#saves").button('loading');
        $.ajax({
            url: basePath + "classroom/addClassroomInfo",
            data: {
                name: $("#classroomName").val().trim(),
                examinationId: $("#examinationId").val(),
                passScore: $("#passScore").val().trim(),
                planTime: $("#planTime").val().trim(),
                memo: $("memo").val().trim()
            },
            dataType: "json",
            type: "POST",
            success: function () {
                $.messager.alert("<spring:message code="prompt"/>", "<spring:message code="add"/><spring:message code="succeed"/>!", "", function () {
                    parent.$("#dataEdit").dialog('close');
                    parent.query();
                });
            },
            error: doError
        })
    }

    function quit() {
        parent.$("#dataEdit").dialog('close');
    }
</script>
